package com.mtk.launcher.activity;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;

import com.lark.wifi.ui.WifiActivity;
import com.mtk.launcher.R;
import com.mtk.launcher.adapter.SettingsAdapter;
import com.mtk.launcher.databinding.ActivitySettingBinding;
import com.mtk.launcher.util.AppVersionUtils;

import java.util.ArrayList;
import java.util.HashMap;

public class SettingActivity extends BaseActivity {

    private ActivitySettingBinding binding;
    private ArrayList<HashMap<String, String>> settingsList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        binding = ActivitySettingBinding.inflate(getLayoutInflater());
        setContentView(binding.getRoot());
        initData();
        initListener();
    }

    private void initData() {
        binding.included.title.setText(getString(R.string.action_settings));
        settingsList = new ArrayList<>();
        HashMap<String, String> wifiSetting = new HashMap<>();
        wifiSetting.put("icon", String.valueOf(R.mipmap.icon_wifi_menu));
        wifiSetting.put("title", "WiFi设置");
        wifiSetting.put("subtitle", "WLAN、偏好设置、流量使用");
        settingsList.add(wifiSetting);

        HashMap<String, String> displaySetting = new HashMap<>();
        displaySetting.put("icon", String.valueOf(R.mipmap.icon_screen_menu));
        displaySetting.put("title", "显示设置");
        displaySetting.put("subtitle", "亮度、角度、定时开关屏");
        settingsList.add(displaySetting);

        HashMap<String, String> timeSetting = new HashMap<>();
        timeSetting.put("icon", String.valueOf(R.mipmap.icon_time_menu));
        timeSetting.put("title", getString(R.string.title_time_date));
        timeSetting.put("subtitle", getString(R.string.title_time_date));
        settingsList.add(timeSetting);

        SettingsAdapter adapter = new SettingsAdapter(this, settingsList);
        binding.lvSetting.setAdapter(adapter);
        binding.lvSetting.setOnItemClickListener(new AdapterView.OnItemClickListener() {
            @Override
            public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
                if (position == 0) {
                    startActivity(new Intent(SettingActivity.this, WifiActivity.class));
                }
                if (position == 1) {
                    startActivity(new Intent(SettingActivity.this, ScreenShowActivity.class));
                }
                if (position == 2) {
                    startActivity(new Intent(SettingActivity.this, TimeAndDateActivity.class));
                }
            }
        });

        String versionCode = AppVersionUtils.getFullVersionInfo(SettingActivity.this);
        binding.tvVersion.setText(versionCode);


    }

    private void initListener() {
        binding.included.llBack.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                finish();
            }
        });
    }

}